<template>
  <div class="systemMenu">
    <div class="header">
      <span class="title">系统</span>
      <addApiBtn :systemId="systemId" @after-op="afterOp" v-if="hasBtn"></addApiBtn>
    </div>

    <div class="tree">
      <el-tree
          :data="data"
          default-expand-all
          :expand-on-click-node="false"
          node-key="id"
          @current-change="currentChange"
          ref="tree"
          highlight-current
          :props="defaultProps">
      </el-tree>

    </div>
  </div>
</template>

<script>
import addApiBtn from "@/views/APImanage/module/addApiBtn";
export default {
  name: "systemMenu",
  props:{
    hasBtn:{
      default:true
    }
  },
  components:{
    addApiBtn
  },
  data() {
    return {
      data: [],
      systemId:'',
      defaultProps: {
        children: 'children',
        label: 'name'
      }
    };
  },
  mounted() {
    this.getApiSystemList()
  },
  methods:{
    afterOp(){
      this.$emit('after-op')
    },
    currentChange(node){
      this.systemId = node.id
      this.$emit('node-select',node)
    },
    getApiSystemList(){
      let params = {
        page:0,
        pageSize:1000
      }
      this.$api.getApiSystemList(params).then(res=>{
        this.data = [
          {
            id: 0,
            name: '模块架构',
            children: res.data.data
          }
        ]
      })
    },
  },
}
</script>

<style scoped lang="less">
/deep/.el-tree{
  background: transparent;
}
.systemMenu{
  width: 200px;
  border-right: 1px solid #eeeeee;
  height: 100%;
  .header{
    width: calc(100% - 40px);
    padding: 0 20px;
    height:44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: white;
  }
  .title{
    //width: 100%;
    height:44px;
    display: inline-block;

    line-height: 44px;
    //text-indent: 20px;
    font-size: 14px;
  }
  .tree{
    width: calc(100% - 10px);
    height: calc(100% - 44px);
    overflow-y: auto;
    background-color:  #FAFAFA;
    padding-left: 10px;
  }
}
</style>